package com.leetcode.No0018;

import java.sql.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

/**
 * @program: Solution
 * @description: 四数之和
 * @author: Wang Zhihua
 * @date: 2022-11-08
 */
public class Solution {

    public List<List<Integer>> fourSum(int[] nums, int target) {
        int len = nums.length;
        // Map<两数之和, List<List<两个数组元素下标>>>
        HashMap<Integer, List<List<Integer>>> map = new HashMap<>();
        for (int i = 0; i < len; i++) {
            for (int j = i + 1; j < len; j++) {
                int sum = nums[i] + nums[j];
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                list.add(j);

                List<List<Integer>> lists;
                map.put(sum, lists = (map.get(sum) == null) ? new ArrayList<>() : map.get(sum));

                lists.add(list);
            }
        }

        for (Integer sum1 : map.keySet()) {
            int sum2 = target - sum1;
            List<List<Integer>> lists2 = map.get(sum2);
            if (lists2 == null) {
                continue;
            }
            List<List<Integer>> lists1 = map.get(sum1);


        }
        return null;
    }

}
